Skip to content

Rename dtype typevar #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

MarcoGorelli
Copy link
Contributor

typevars usually end with T to distinguish them from type aliases : https://pylint.pycqa.org/en/latest/user_guide/messages/convention/invalid-name.html

I'd suggest we make the typevar DTypeT, and then introduce a type alias DType, which would resolve #189

@MarcoGorelli MarcoGorelli force-pushed the rename-dtype-typevar branch from 68e08c0 to 42e6975 Compare July 12, 2023 10:54
@rgommers
Copy link
Member

I'd suggest we make the typevar DTypeT, and then introduce a type alias DType, which would resolve #189

That sounds reasonable to me. Wouldn't you want to introduce the alias in this same PR, so that the signatures and how they're rendered don't change?

@rgommers rgommers added the static typing type annotations, use of type checkers directly from the spec label Jul 12, 2023
@rgommers
Copy link
Member

Hmm, that didn't completely work, maybe because of the if TYPE_CHECKING. In the preview for this PR we have for Column.get_rows (as an example):

get_rows(indices: Column[Any]) → Column[DtypeT]

so compared to in main, Dtype changed to DtypeT: Column.get_rows

@MarcoGorelli
Copy link
Contributor Author

MarcoGorelli commented Jul 13, 2023

Isn't that one correct? DTypeT is the typevar, so that's what we need to use in Column[

image

So, we use DType when annotating dtype, e.g. in column_from_sequence, and DTypeT when narrowing down the type of a generic Column (Column[DTypeT])

@rgommers
Copy link
Member

Oh wait, I was looking at a partial diff, you actually did change the get_rows signature in this PR still. I thought the point of our discussion on type aliases was to revert that, and only use DType. A "typevar" does not belong in any html rendering, it's an irrelevant type-checking detail to the reader.

@MarcoGorelli
Copy link
Contributor Author

happy to agree to disagree on this one, closing then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
static typing type annotations, use of type checkers directly from the spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DType parent class / type alias
2 participants